#include <stdio.h>
#include <stdlib.h>
typedef struct node {
    int coefficient;
    int index;
    struct node* next;
}node;
node* input();
void derivation(node* a);
void output(node* L);
int main()
{
    node* a = input();
    derivation(a);
    output(a);
    return 0;
}
node* input()
{
    node* s = (node*)malloc(sizeof(node));
    s->next = NULL;
    node* m = s;
    for (int i = 0; i < 1000; i++)
    {
        node* p = (node*)malloc(sizeof(node));
        scanf("%d%d", &p->coefficient, &p->index);
        if (p->index == 0)
        {
            break;
        }
        m->next = p;
        m = p;
    }
    m->next = NULL;
    return s;
}
void output(node* L)
{
    int flag = 0;
    L = L->next;
    if (L)
        while (L)
        {
            if (!flag)
                printf("%d %d", L->coefficient, L->index);
            else
                printf(" %d %d", L->coefficient, L->index);
            flag++;
            L = L->next;
        }
    else
        printf("0 0");
    printf("\n");
}
void derivation(node* a)
{
    node* p1; p1 = a;
    node* p2;
    while (p1)
    {
        p1->coefficient = p1->coefficient * p1->index;
        p1->index = p1->index - 1;
        p1 = p1->next;
    }
}